home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1599 / 1328 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  1.5 KB

  1. Date: Tue, 26 Apr 94 18:43:52 PDT
  2. From: brad@tazboy.Jpl.Nasa.Gov (Brad Pickering)
  3. Message-Id: <9404270143.AA25944@tazboy.JPL.NASA.GOV>
  4.     id AA04259; Tue, 26 Apr 94 17:46:08 PDT
  5. To: mint@atari.archive.umich.edu
  6. Subject: mint library fgetc
  7.  
  8. I have been playing around with Scheme->C under MiNT, trying
  9. to track down why it doesn't work the same as under UNIX on
  10. the Sun.  If anybody has ported Scheme->C to MiNT, could you
  11. let me know.
  12.  
  13. My first problem is in the interpretation of ^D (EOF). S2C has the
  14. following code for reading characters.  On the Sun, ^D on a tty causes
  15. getc to return EOF, and feof() to return TRUE, so EOFOBJECT is
  16. returned.  Under MiNT, ^D on the console returns EOF, but feof()
  17. returns FALSE.
  18.  
  19. Scheme->C code for getc:
  20.  
  21.     character = getc( stream );
  22.     if  (character == EOF)   {
  23.        if  (feof( stream ))  {
  24.           clearerr( stream );
  25.           return( EOFOBJECT );
  26.        }
  27.        else  
  28.           return( CSTRING_TSCP( strerror( ferror( stream ) ) ) );
  29.     }
  30.     return( C_CHAR( character ) );
  31.  
  32. Below is part of the code for filbuf in the MiNT library.  It looks
  33. like the EOF flag is not set if the file has the IODEV flag set.  I
  34. don't think this code should care what kind of device it is reading
  35. from.  What do you think?
  36.  
  37. MiNT filbuf code:
  38.  
  39.     fp->_ptr = fp->_base;
  40.     if((got = _read(fp->_file, fp->_base, (unsigned long)fp->_bsiz)) <= 0)
  41.     {   /* EOF or error */
  42.     fp->_flag |= ((got == 0) ? ((f & _IODEV) ? 0 : _IOEOF) : _IOERR);
  43.     fp->_cnt = 0;
  44.     return EOF;
  45.     }
  46.     fp->_cnt = got - 1;
  47.     return *(fp->_ptr)++;
  48.  
  49.  
  50. Brad
  51.